System and method for context-based serialization of messages in a parallel execution environment

ABSTRACT

A messaging system and method which allows parallel execution of related requests according their context-based sequence. A serialization processor receives each incoming message request from a messaging client, extracts a transaction identifier (TI), searches a state table for the TI, and, if the TI is found active in the state table, stores the request in a serialization queue and makes an entry for that TI with the state “queued” in the state table. After execution of the active request, its entry in the state table is cleared, and the queued request with the same TI is executed, whereupon its entry is changed from queued to active.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a Divisional of U.S. application Ser. No.10/685,160, filed on Oct. 14, 2003, which claims priority to EuropeanApplication No. 02027972.5, filed Dec. 13, 2002, now U.S. Pat. No.7,895,328, which is incorporated herein by reference in its entirety.

FIELD OF THE INVENTION

The present invention relates generally to messaging, and moreparticularly relates to messaging in a parallel execution environment.

BACKGROUND

Messaging, as discussed here, may be defined as a method that allows twoentities to communicate by sending and receiving messages withoutrequiring human interaction. One of the most important aspects ofmessaging is its asynchronous nature: the sender of the message does notneed to wait for the recipient to receive the information. Sendingapplications are free to generate messages at an appropriate speed,handling peak periods as they occur, without having to wait forrecipients to deal with the requests.

Messaging methods vary in their implementations. Two of the most commonimplementations are the hub-and-spoke architecture and the busarchitecture.

In the hub-and-spoke architecture, applications are connected to acentral processor, which may be called a message server. The messageserver handles all communication among the connected applications, whichare called the application clients. An application client can be asender of a message, a recipient, or both.

The message server is responsible for routing messages correctly,authenticating and authorizing user access, and guaranteeing thedelivery of messages.

A bus architecture does not have a centralized message server tocoordinate the distribution of messages. Instead, each applicationclient includes the functionality typically found in a message server.Application clients are connected to a message bus, which typically usesthe network layer of the IP multicast protocol. Although the multicastnetwork layer routes messages among each of the application clients, theclients must perform all checks and balances to ensure that the messagesare delivered securely and reliably.

One of the major problems of today's messaging methods concerns theexecution of related requests in a parallel execution environment. InFIG. 1, clients 10A-10N send messages to execution systems 17A and 17Bthrough a message queue 14. For example, a client sends a paymentmessage request to a bank. If the client sends another related requestimmediately following the payment request, e.g., to modify or cancel thepayment request, the messaging method must always preserve the order ofthe original sequence of requests to guarantee a consistent execution.In a sequential execution environment there is no problem, since allrequests are executed according to their original sequence.

In a parallel execution environment, however, e.g., an environment wherethe target system has two or more processors, preservation of thecontext-based sequence cannot be guaranteed. The parallel executionsystem starts a new thread for each incoming message request andexecutes requests without regard to their intended order. This maytranspose the execution of two consecutive requests that are related.For example, a request to cancel a payment request may be executedbefore the payment request itself. Here, the request to cancel thepayment request fails because there is nothing to cancel at the time thecancellation is executed, and the payment subsequently goes throughdespite its intended cancellation.

Existing messaging systems, for example the IBM MQ Series, do notprovide any functionality for processing context-based requests inparallel execution environments without human interaction.

Thus, there is a need to provide an improved messaging system and methodwhich is applicable in a parallel execution environment and whichguarantees the automatic execution of related requests according theircontext-based or original sequence, without requiring human interaction.

SUMMARY

The present invention includes an improved messaging system and methodwhich allows parallel execution of related requests according theircontext-based sequence by using a serialization processor. Theserialization processor receives each incoming message request from themessaging client, retrieves a transaction identifier (TI), and checks astate table for the retrieved TI. When the TI is found already stored inthe state table with the state “active,” the serialization processorstores the new requests with the same TI in a serialization queue andmakes an new entry for that TI with the state “queued” in the statetable. Once an active request has been executed, its entry in the statetable is cleared. The queued request with the same TI is executed by theexecution system, and its entry is updated from the state “queued” tothe state “active.” In a preferred embodiment of the present invention,the headers of message requests may contain message identifiers (MI),which mark the message requests as context-based-serial. Messagerequests that do not have a message identifier are executed withoutinvolvement of the serialization processor.

These and additional features and advantages of the present inventionwill become more apparent from the detailed description set forth belowwhen taken in conjunction with the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings illustrate embodiments of the presentinvention and, together with the description, further serve to explainthe principles of the embodiments of the present invention.

FIG. 1 shows an example of the messaging system having a parallelexecution environment according to the prior art.

FIG. 2 shows incorporation of the present invention into a parallelexecution environment.

FIG. 3 shows a typical hub-and-spoke messaging system where multipleclients put their messages into a message queue.

FIG. 4 shows a typical message suitable for use by the inventiveserialization processor.

FIG. 5 shows an example of a message header of the message system of theIBM MQ Series.

FIG. 6 shows a typical message queue layout suitable for use by theinventive serialization processor.

FIG. 7 shows a preferred structure of the state table as used by theinventive serialization processor.

FIG. 8 shows a flowchart illustrating steps of a method performed by theinventive serialization processor.

DETAILED DESCRIPTION

The following hardware and software provide a suitable context forimplementation of the present invention: a messaging client installed atthe client side, for example the IBM MQ Series Client; a networkconnection to the server system; and an operating system depending onthe clients, for example Microsoft Window 2000 for PC-based clients. Atthe server side a messaging server is needed, for example the IBM MQSeries Server. A state table as proposed by the present invention may beimplemented using a data base management system such as the IBM DB2. Theserver should have a multi-tasking operating system like Windows 2000.

As shown in FIG. 3, clients 10A-10N put their message requests 12 into amessage queue 14 which is managed by a queue manager 15. If the messageheader of an incoming message defines that message as persistent, themessage is then stored persistently; otherwise it is storednon-persistently. Non-persistent messages reside in the memory only, andmay get lost if the queue manager 15 crashes. Persistent messages arestored on a persistent medium, for example a disk, and cannot beinadvertently lost. Each of the clients 10A-10N includes a clientinterface layer in order to communicate with the queue manager 15 at theserver side.

The inventive serialization processor 16 gets each message 12 from themessage queue 14, and analyzes the message to find the transactionidentifier (TI) if the message context indicates that the message has aTI. The transaction identifier may be defined as an identifier in amessage which identifies all messages belonging to the same businesstransaction. Then the serialization processor 16 searches a state table18, which is preferably realized as a table in a database system. Thestate table 18 provides information regarding which messages are“queued” or “active” (being executed). The query returns two possibleresults: either the TI cannot be found in the state table 18, or the TIis found in the state table 18 with the state “active.”

When the TI cannot be found in the state table 18, the serializationprocessor 16 creates a new entry in the state table 18 that contains thenew TI and the state “active.” Then the serialization processor 16 putsthe message into one of the execution queues 19A, 19B shown in FIG. 2.The message is then executed by one of the threads of the connectedexecution system 17A, 17B. When the thread is finished processing butbefore it closes, the TI is cleared in the state table 18.

When the TI is found in the state table 18 with the state “active,” thenew message will be put into a serialization queue 20. In theserialization queue 20, the message is held until the active thread hasfinished and the TI has cleared in the state table 18. If a furthermessage that has the same TI arrives at the message queue 14, the newlyarrived message will be put into the serialization queue 20.

From time to time, the serialization processor 16 checks for messagesheld in the serialization queue 20. A number of different mechanisms maytrigger this check in different embodiments. For example, a timerinterrupt may cause the serialization processor 16 to check for messagesin the serialization queue 20. In another embodiment, the executingthread may set a flag to inform the serialization processor 16 that ithas finished its task and has cleared the TI in the state table 18. Ifthe serialization processor 16 is triggered by such an event, it checksthe serialization queue 20 for messages, and if a message is found,determines whether the TI has already been cleared from the state table18. If the TI has been cleared, the message is removed from theserialization queue 20 and put into one of the execution queues 19A, 19Bfor processing.

The present invention may also be implemented as follows: When thetransaction identifier is found in the state table 18 with the state“active,” the new message may be put into the serialization queue 20,and a new entry created for that message in the state table 18 with thestatus “queued.” After a defined time interval, the serializationprocessor 16 checks the state table 18, and changes the state to“active” once the related messages with the entry “active” have beencleared.

FIG. 3 shows a typical hub-and-spoke messaging system where multipleclients 10A-10N put their messages into a message queue 14. Each of theclients 10A-10N has a client interface 11A-11N with the queue manager15. Furthermore, the inventive serialization processor 16 (which, in theinterest of simplicity, is not shown in FIG. 3) has an interface withthe queue manager 15 as well as with the application system. Theserialization processor 16 ensures that an application thread isassigned to a message only when the serialization processor 16 puts themessage into one of the execution queues 19A, 19B.

FIG. 4 shows a typical message layout suitable for use by theserialization processor 16. The message 12 includes a message header 24and a message body 26. The message header 24 normally includes a messageidentifier, a source queue name, a target queue manager, the targetqueue name, the message type, and a code page used for the message body26. Messages lacking a context-based identifier are treated asunrelated, and do not need to be executed by the serialization processor16. The message body 26 normally contains the transaction identifier(TI) and the user (application) defined data.

The message body 26 is handled primarily by the execution or applicationsystem rather than the messaging system. Consequently, a traditionalmessage system itself cannot react to a TI that is part of the messagebody 26. Therefore, the TI is inspected by the serialization processor16 in order to avoid parallel execution for two messages which belong tothe same TI. FIG. 5 shows an exemplary message header of the IBM MQSeries message system, which may be used by the present invention.

FIG. 6 shows preferred embodiment of the message queue 14 as used by thepresent invention. Messages are put into the message queue 14 by theclients 10A-10N. On the right-hand side of FIG. 6, the server side,messages are taken out by the serialization processor 16. In theinventive messaging system as described here, each message taken out ofthe message queue 14 creates a new application thread which handles thebody of the message. There may be multiple server machines connected tothe same queue, taking the messages in parallel.

FIG. 7 shows a preferred embodiment of the state table 18 as used by thepresent invention. Each incoming new message request contains atransaction identifier (TI) 28 in its message body. The serializationprocessor 16 checks the state table 18 to determine whether thistransaction identifier 28 is already stored, and whether the transactionstate 30 is active. If both conditions are satisfied, the transactionidentifier 28, the state 30 “queued,” and the message ID 33 taken fromthe message header 24 are stored in the state table 18 together with atime stamp 36 recording the arrival time of the new message. The statetable 18 may preferably be implemented as a persistent table in a database system, with columns for the transaction ID, message ID, and timestamp. This ensures that messages will not be lost.

If an incoming message request contains a TI which is not found in thestate table 18, the new TI is stored in the state table 18 with thestate 30 “active,” together with its arrival time (time stamp 36) andthe message ID 33 from the message header. Then the message is deliveredto an application thread for processing. When the tread has completedits processing, the entry is cleared from the state table 18.

The possible transaction states 30 in the state table 18 are active andqueued. The state “active” indicates that another message with the sameTI is currently being processed by one of the application threads. Thestate “queued” indicates that another message with the same TI isalready queued, and is waiting for processing, in which case the newmessage will also be queued.

The message ID 33 may also be stored in the state table 18, and isneeded in order to retrieve the correct message from the serializationqueue 20 when the processing of the active transaction is finished.

Furthermore, the time stamp 36 of the arrival time of the message isneeded when more than one entry with the same TI is found in the statetable 18. In this case, the saved messages must be put into theapplication queues according to the arrival sequence.

To ensure that requests are not lost, a logical unit of work (LUW) mustspan all activities necessary to process a message. A LUW will bestarted when a message is received from the message queue 14. Then, thedata base holding the state table 18 is accessed to find the transactionidentifier 28, after the message is put into one of the execution queues19A, 19B. The state table 18 is updated to reflect the new transactionidentifier 28. Then a commit operation must be issued which commits allactivities. This guarantees that the present message is deleted from themessage queue 14, that the message is available for processing in theexecution queue 19A or 19B, and that the transaction identifier 28 isstored in the state table 18. The same transaction processing must beperformed when a saved message is taken out of the serialization queue20 and sent to one of the execution queues 19A, 19B for processing.

FIG. 8 shows a flowchart of a process according to the inventive method.The client application may be, for example, a payment application. Theuser creates a payment message which includes the following data: theamount of money to be paid, the sender, the receiver, and a transactionidentifier. The payment application creates, using the message client, apayment message (step 100). The payment message contains a messageheader and message body as mentioned earlier with reference to FIG. 5.The payment message is sent to the message server by means of themessage client and the network (step 150).

The message server receives the payment message and puts the paymentmessage into the message queue 14 using the queue manager 15 (step 200).The queue manager 15 stores the payment message persistently ornon-persistently, depending on the data in the message header. Theserialization processor 16 takes the payment message from the messagequeue (step 250), analyses the payment message for the transactionidentifier (step 300), and searches the state table 18 for the sametransaction identifier (step 350).

If the transaction identifier is not already contained in the statetable 18 (step 400), the serialization processor 16 creates a new entryin the state table 18 with the transaction identifier of the newmessage, its message ID, its time stamp, and its state “active” (step500), and sends the payment request to the execution system forprocessing of the payment message (step 600). After the payment messageis executed by the execution system or application, the entry in thestate table 18 is cleared (step 700).

Otherwise (i.e., the transaction identifier is already stored in thestate table 18) (step 450), the serialization processor 16 puts the newpayment message into the serialization queue 20 (step 550) and, once thesame transaction identifier has been cleared in the state table 18, theserialization processor 16 sends the payment message to the executionsystem for processing (step 650).

In another embodiment of the present invention, the new message is sentto the serialization queue 20, and a new entry for the new message iscreated in the state table 18 with the status “queued.” After a definedtime interval, the serialization processor 16 checks the state table 18and changes the state “queued” to the state “active” once the relatedmessage with the entry “active” has been cleared.

We claim:
 1. A messaging system for context-based serialization ofmessages in a parallel execution environment, comprising a serializationprocessor executing in a memory of a computer for receiving an incomingmessage from a message client, extracting a transaction identifier fromthe message, checking a state table for the transaction identifier,putting the message into a serialization queue if the transactionidentifier is found with an active status in the state table, andputting the message into an execution queue once the transactionidentifier has been cleared in the state table.
 2. The messaging systemaccording to claim 1, wherein, if the transaction identifier with thestate active is found in the state table, the serialization processormakes an entry in the state table with a status of queued and puts themessage into the serialization queue.
 3. The messaging system accordingto claim 1, wherein the serialization processor creates time stampentries in the state table, wherein a time stamp entry defines anarrival time of a message, and the serialization processor puts messagesinto the execution queue in a sequence according to the time stamps. 4.The messaging system according to claim 1, wherein the serializationprocessor creates a message ID entry in the state table for use by theserialization processor to retrieve messages from the serializationqueue.
 5. A server system, comprising: a messaging server executing inmemory of a computer and communicating with a messaging client; a queuemanager for managing a message queue; and an execution system forparallel processing of messages; wherein the server system includes: aserialization queue for storing messages to be queued; an executionqueue for storing messages to be executed; a state table providing stateinformation; and a serialization processor for taking messages from themessage queue responsive to the state information and updating the statetable accordingly.
 6. The server system according to claim 5, whereinthe state table comprises a transaction identifier and present state ofa message, wherein the present state may be active or queued.
 7. Theserver system according to claim 6, wherein the state table furthercomprises a time stamp which records the arrival time of the message. 8.The server system according to claim 7, wherein the state table furthercomprises a message identifier for a message for retrieval of themessage from the serialization queue.
 9. The server system according toclaim 5, wherein the serialization processor receives an incomingmessage from the messaging client via the message queue, reads atransaction identifier included in the message, checks the state tablefor the transaction identifier, puts the message into a serializationqueue if the transaction identifier is already stored in the state tablewith the state active, and puts the message into an execution queue ifthe entry in the state table with the transaction identifier has beencleared.
 10. The server system according to claim 9, wherein theserialization processor makes an entry in the state table with a statusof queued if the transaction identifier is already stored in the statetable with the state active.